package com.MovieManageSystem.controller;

import com.MovieManageSystem.domain.Collection;
import com.MovieManageSystem.entity.Result;
import com.MovieManageSystem.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/collection")
@CrossOrigin(origins = "*")
public class CollectionController {
    @Autowired
    private CollectionService collectionService;

    @GetMapping
    public Result getCollectionList(Collection collection){
        List<Collection> deptList = collectionService.getCollectList(collection);
        return Result.success(deptList);
    }

    /**
     * 新增收藏
     */
    @PostMapping
    public Result add(@RequestBody Collection collection)
    {
        collectionService.insertCollection(collection);
        return Result.success();
    }

    /**
     * 删除收藏
     */
    @DeleteMapping("/delete/{cid}")
    public Result remove(@PathVariable Long cid)
    {
        collectionService.deleteCollectionByCid(cid);
        return Result.success();
    }

}
